home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / qb1 / pro10 / dialtsr.bas < prev    next >
Encoding:
BASIC Source File  |  1990-08-06  |  4.7 KB  |  117 lines

  1. '======================================================================
  2. '=  DialTSR  (TSR Phone Dialer Demonstration)                         =
  3. '=  by Jonathan Zuck                                                  =
  4. '=  Copyright 1990, User Friendly, Inc.                               =
  5. '=                                                                    =
  6. '=       bc dialtsr /o;                                               =
  7. '=       link /noe /nod dialtsr str00512 _noval _noread , , nul , pdq =
  8. '=       exe2com dialtsr                                              =
  9. '=                                                                    =
  10. '======================================================================
  11.  
  12. DEFINT A-Z
  13. '$INCLUDE: 'PDQDECL.BAS'
  14.  
  15. DIM Registers AS RegType                'RegType is defined in PDQDECL.BAS
  16. One = 1                                 'these variable save code size below
  17. Two = 2
  18. Three = 3
  19. Seven = 7
  20.  
  21. DialStr$ = "ATDT"                       'These are for Hayes compatible
  22. HangStr$ = "ATH"                        '  modems
  23.  
  24. 'I chose to use the BIOS here for a number of reasons:
  25. '  1. There is less code overhead
  26. '  2. There are fewer compatibility questions
  27. '  3. It parallels the FNBIOSPrint routine in SETUPTSR.BAS and as
  28. '     such has greater application then OUTs
  29.  
  30.  
  31.  
  32. DEF FNBIOSDial% (Character)
  33.     FNBIOSDial% = 0                     'assume no errors
  34.     Registers.AX = 256 + Character      'put the character into AL, 1 into AH
  35.     Registers.DX = 0                    'specify Com1: (use 1 for Com2: etc.)
  36.     Interrupt &H14, Registers           'call the BIOS write service
  37.     PRINT HEX$(Registers.AX)
  38.     IF Registers.AX AND &H8000 THEN     'check bit 7 of AH, error if set
  39.        FNBIOSDial% = -1
  40.     END IF
  41. END DEF
  42.    
  43. 'Modem initialization, only need once and it doesn't matter if the underlying
  44. 'applications change it.  In fact, if you have executed a command like:
  45. '   MODE COM1:9600,N,8,1,P
  46. 'you don't need to initialize at all
  47.  
  48. Registers.AX = 67                       'put the character into AL, 0 into AH
  49. Registers.DX = 0                        'specify Com1: (use 1 for Com2: etc.)
  50. Interrupt &H14, Registers               'call BIOS
  51.  
  52. ID$ = "ResDial (c) 1990 User Friendly, Inc. - press Ctrl-D to activate"
  53. Row = CSRLIN                            'print at the current cursor location
  54. Column = POS(0)
  55.  
  56. PDQPrint ID$, Row, Column, Seven
  57.  
  58. ScrnSize = 480                          '3 lines * 80 cols for prompt & input
  59. BufSeg = AllocMem%(ScrnSize)            'allocate memory to save the screen
  60. DEF SEG = 0                             'see what type of monitor
  61. IF PEEK(&H463) = &HB4 THEN ScrSeg = &HB000 ELSE ScrSeg = &HB800
  62. Num2Dial$ = "                                 "
  63.  
  64. '----- set up the TSR as a pop-up using Ctrl-D
  65. CALL PopUpHere(&H420, ID$)              'Ctrl-D, pass the unique ID string
  66. GOTO EndIt                              'skip past the interrupt handler below
  67.  
  68. '----- the following code is invoked each time Ctrl-D is pressed
  69.  
  70. BlockCopy ScrSeg, Zero, BufSeg, Zero, ScrnSize  'save the underlying screen
  71. Row = CSRLIN                                    'and the cursor location too
  72. Column = POS(0)
  73.  
  74. '----- draw a box and prompt for the phone number
  75. PDQPrint "┌─────────────────────────────────────────────────────────────────┐", One, One, Seven
  76. PDQPrint "│ Enter a phone number to dial:                                   │", Two, One, Seven
  77. PDQPrint "└─────────────────────────────────────────────────────────────────┘", Three, One, Seven
  78.  
  79. LOCATE 2, 33                                 'position the cursor
  80. BIOSInput Num2Dial$, 112                     'get number
  81.  
  82. 'This is where we dial the number:
  83.    
  84. FOR X = 1 TO 4
  85.     Char = ASC(MID$(DialStr$, X, One))       'first send the "ATDT"
  86.     ComErr = FNBIOSDial%(Char)
  87.     IF ComErr THEN GOTO NoCom
  88. NEXT
  89.         
  90. FOR X = 1 TO 33                              'now the number, spaces ignored
  91.     ComErr = FNBIOSDial%(ASC(MID$(Num2Dial$, X, One)))
  92.     IF ComErr THEN GOTO NoCom
  93. NEXT
  94.         
  95. ComErr = FNBIOSDial%(13)                     'all AT commands terminate with
  96. IF ComErr THEN GOTO NoCom                    'a CR
  97.  
  98.  
  99. PDQPrint "Dialing, hit a key to hang up:", Two, Three, Seven
  100.  
  101. WHILE BIOSInkey% = 0: WEND                   'Now pick up the phone...
  102. FOR X = 1 TO 3                               'and hang up the modem
  103.     ComErr = FNBIOSDial%(ASC(MID$(HangStr$, X, One)))
  104.     IF ComErr THEN GOTO NoCom
  105. NEXT
  106.  
  107. NoCom:
  108. BlockCopy BufSeg, Zero, ScrSeg, Zero, ScrnSize  'restore the screen contents
  109. LOCATE Row, Column                              'and the cursor location
  110.  
  111.  
  112. CALL PopDown                                    'back to underlying app.
  113.  
  114. EndIt:
  115. CALL EndTSR(ID$)                        'this installs us as a TSR
  116.  
  117.